﻿$(function () {
    //$('.content_area_syn .left ul li').hover(function () {
    //    $(this).addClass("cur");
    //},function(){
    //    $(this).removeClass("cur");
    //});
    $('.content_area_syn .left ul li').bind("click", function () {
        $(this).addClass("cur").siblings().removeClass("cur");
    });
    $("#startxuexi").bind("click", function () {
        $("#example_video_1")[0].focus();
        var heighe = $("#example_video_1").offset().top;
        $("body").scrollTop(heighe);
    });
   
    //$(".yixue").bind("click", function () {
    //    $('.weixue').css("display", "inline");
    //    $('.yixue').css("display", "none");
    //});

    $('.content_area_syn .left ul li a').bind("click", function () {
        var videlurl, fengmianurl;
        //视频url
        var videlurl = $(this).attr("data-shipinurl");
        //封面url
        var fengmianurl = $(this).attr("data-fengminurl");
        //视频name
        var name = $(this).attr("title");
        //视频id
        var shipinid = $(this).attr("data-shipinid");
        //视频学习标识data-biaoshis
        var shipinbiaoshi = $(this).attr("data-biaoshi");
        console.log(videlurl);
        console.log(fengmianurl);
        //获得视频对象
        var myPlayer = videojs('example_video_1');
        //设置视频封面
        myPlayer.poster(fengmianurl);
        //设置视频的source属性
        myPlayer.src(videlurl);
        myPlayer.play();
        console.log(shipinbiaoshi);
        $("#buttumname").empty().append(name);
        $("#shipinid").empty().append(shipinid);
        if (shipinbiaoshi == 1){
            $('.yixue').css("display", "inline");
            $('.weixue').css("display", "none");
        }
        else {
            $('.yixue').css("display", "none");
            $('.weixue').css("display", "inline");
            $(".weixue").bind("click", function () {
                var id = $(this).parent().find("h3").text();
                if (id == "") {
                    alertwin("警告","请先学习，再来标记！！");
                }
                else {
                    $('.yixue').css("display", "inline");
                    $('.weixue').css("display", "none");
                    //视频id
                    console.log(id);
                    $.ajax({
                        type: "POST",
                        url: "/addshipin/study",
                        data: "id=" + id,
                        success: function (msg) {
                            console.log("成功" + msg);
                            window.location.href = window.location.href;
                        }
                    });
                }

            });
        }
      
    });

    function alertwin(tilele, content) {
        $.alert({
            title: tilele,
            content: content,
            confirmButton: '确认',
            columnClass: 'col-md-4 col-md-offset-4',

        });
    }
})